Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solution #1013

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

solution #1013

wants to merge 12 commits into from

Conversation

Absolution26
Copy link

@Absolution26 Absolution26 commented Jan 11, 2024

Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job 👍
Let's improve your code

className="input is-danger"
className={cn('input', { 'is-danger': hasNameError })}
value={inputName}
onChange={event => handleChangeName(event)}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onChange={event => handleChangeName(event)}
onChange={handleChangeName}

aria-label="delete"
{!error && Boolean(comments.length)
&& !isLoadingComments
&& comments.map(comment => (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a destruction for comment

Comment on lines 53 to 55
{openPostId === post.id
? 'Close'
: 'Open'}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{openPostId === post.id
? 'Close'
: 'Open'}
{openPostId === post.id ? 'Close' : 'Open'}

Comment on lines 37 to 43
{!selectedUser
? (
<span>Choose a user</span>
)
: (
<span>{selectedUser?.name}</span>
)}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check can be placed inside the span tag

@mgrinko mgrinko closed this Jan 12, 2024
@mgrinko mgrinko reopened this Jan 12, 2024
Copy link

@loralevitska loralevitska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to pass all tests, if you have any questions, please ask them in fe_chat and tag mentors. It will be faster, because your answers in GitHub will be visible to mentor only after you re-request review

image
image

  • hide this block after user was changed
    image

src/App.tsx Outdated
Comment on lines 115 to 119
{(!isLoadingPosts
&& posts.length > 0
&& selectedUser
&& !errorPosts)
&& (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long expression better move to variable with meaningful variable naming

<td data-cy="PostId">{post.id}</td>

<td data-cy="PostTitle">
{post.title}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Destructure post


<tbody>
{posts.map(post => (
<tr

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better move it to separate component Post

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not fixed

Comment on lines 52 to 59
<a
key={user.id}
href={`#user-${user.id}`}
className="dropdown-item"
onClick={() => updateUserAndPosts(user)}
>
{user.name}
</a>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Destructure user and move this code to common component User

const [posts, setPosts] = useState<Post[]>([]);
const [comments, setComments] = useState<Comment[]>([]);
const [selectedUser, setSelectedUser] = useState<User | null>(null);
const [selectedPost, setSelectedPost] = useState<Post | null>(null);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why do we need selectedPost when we have openPostId? Isn't it about the same selected/opened post?

Comment on lines 21 to 23
const [hasNameError, setHasNameError] = useState(false);
const [hasMailError, setHasMailError] = useState(false);
const [hasTextareaError, setHasTextareaError] = useState(false);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to store these in the state. These values are derived from above ones

const [hasNameError, setHasNameError] = useState(false);
const [hasMailError, setHasMailError] = useState(false);
const [hasTextareaError, setHasTextareaError] = useState(false);
const [isAdding, setIsAdding] = useState(false);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same for this one

Comment on lines 62 to 65
{!error
&& Boolean(comments.length)
&& comments
&& !isLoadingComments

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better move this to a variable

Comment on lines 69 to 70
{!error && Boolean(comments.length)
&& !isLoadingComments

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here


<tbody>
{posts.map(post => (
<tr

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not fixed

Copy link

@maxim2310 maxim2310 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants